package org.example.im.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.example.im.bean.protocol.response.CreateGroupResponsePacket;
import org.springframework.stereotype.Component;

/**
 * @author dingrui
 * @since 2022/2/12
 * @description 创建群
 */
@Component
public class CreateGroupHandler extends SimpleChannelInboundHandler<CreateGroupResponsePacket> {

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, CreateGroupResponsePacket createGroupResponsePacket) throws Exception {
        if (!createGroupResponsePacket.isSuccess()) System.out.println("[C-CreateHandler] 建群失败");
        else
            System.out.println("[C-CreateGroup] 建群成功 群id[" + createGroupResponsePacket.getGroupId() + "] 群成员[" + createGroupResponsePacket.getUserNameList() + "]");
    }
}
